package com.rambar.weeklyweatherwidget.util;

import java.util.HashMap;

import android.graphics.Bitmap;
import android.view.View;
import android.widget.RemoteViews;

public class WidgetEnvironmentManager {	
	public class WidgetEnvironment {
		private String mMode;
		private RemoteViews mRv;
		private Bitmap mGraphBitmp;
	}
	
	private static WidgetEnvironmentManager widgetEnvironment = null;
	private HashMap<Integer, WidgetEnvironment> mMap = new HashMap<Integer, WidgetEnvironment>();
	
	private WidgetEnvironmentManager() {
	}
		
	public static WidgetEnvironmentManager getInstance() {
		if(widgetEnvironment == null)
			widgetEnvironment = new WidgetEnvironmentManager();
		
		return widgetEnvironment;
	}
	
	private WidgetEnvironment getWidgetEnvironment(int appId) {
		WidgetEnvironment env = mMap.get(new Integer(appId));
		if (env == null) {
			env = new WidgetEnvironment();
			mMap.put(new Integer(appId), env);
		}
		
		return env;
	}
	
	public Bitmap getGraphBitmp(int appId) {
		WidgetEnvironment env = getWidgetEnvironment(appId);
		return env.mGraphBitmp;
	}
	
	/*
	public int toggleMode(int appId){
		int mode = getMode(appId);
		
		if(mode == WidgetEnvironment.MODE_DEGREE_SKY)
			mode = WidgetEnvironment.MODE_DEGREE_GRAPH;
		else if(mode == WidgetEnvironment.MODE_DEGREE_GRAPH)
			mode = WidgetEnvironment.MODE_DEGREE_SKY;
		
		setMode(appId, mode);
		
		return mode;
	}*/
	
	public void setMode(int appId, String mode){
		WidgetEnvironment env = getWidgetEnvironment(appId);
		env.mMode = mode;
	}
	
	public void setRemoteViews(int appId, RemoteViews rv){
		WidgetEnvironment env = getWidgetEnvironment(appId);
		env.mRv = rv;
	}
	
	public String getMode(int appId){
		WidgetEnvironment env = getWidgetEnvironment(appId);
		return env.mMode;
	}
	
	public RemoteViews getRemoteViews(int appId){
		WidgetEnvironment env = getWidgetEnvironment(appId);
		return env.mRv;
	}
}
